//页面UA判断
export function browserUa(){
    //获取浏览器UA
    let browser = {
      isWindowsPhone:false,
      isSymbian:false,
      isAndroid:false,
      isFireFox:false,
      isChrome:false,
      isTablet:false,
      isPhone:false,
      isPc:false,
    }
    let ua = navigator.userAgent
    browser.isWindowsPhone = /(?:Windows Phone)/.test(ua)
    browser.isSymbian = /(?:SymbianOS)/.test(ua) || browser.isWindowsPhone
    browser.isAndroid = /(?:Android)/.test(ua)
    browser.isFireFox = /(?:Firefox)/.test(ua)
    browser.isChrome = /(?:Chrome|CriOS)/.test(ua)
    browser.isTablet = /(?:iPad|PlayBook)/.test(ua) || (browser.isAndroid && !/(?:Mobile)/.test(ua)) || (browser.isFireFox && /(?:Tablet)/.test(ua))
    browser.isPhone = /(?:iPhone)/.test(ua) && !browser.isTablet
    browser.isPc = !browser.isPhone && !browser.isAndroid && !browser.isSymbian;
    return browser
}

export function getCookie(cookieName) {
  const strCookie = document.cookie
  const cookieList = strCookie.split(';')
  console.log('cookie = ' + strCookie)
  for(let i = 0; i < cookieList.length; i++) {
    const arr = cookieList[i].split('=')
    if (cookieName === arr[0]) {
      return arr[1]
    }
  }

  return null
}

export function getDateString(timeStamp){
  let date = new Date(timeStamp);
  let hours = date.getHours()
  let minutes = date.getMinutes()
  let seconds = date.getSeconds()
  return hours + ":" + minutes + ":" + seconds;
}
